﻿@model Seven.Site.Models.AccountModel.MainPageModel
@{
    ViewBag.Title = "Home Page";
}
<link href="~/Content/mainPage/mainPage.css" rel="stylesheet" />
<script src="~/Scripts/mainpage/logout.js"></script>
<script src="~/Scripts/mainpage/authmenus.js"></script>
<script src="~/Scripts/jquery-easyui-extensions/jeasyui.extensions.theme.js"></script>
<script src="~/Scripts/mainpage/mainpage.js"></script>
@if (Model.UserPool)
{
    <script src="~/Scripts/jquery-plugins/signalR/jquery.signalR-2.1.2.min.js"></script>
    <script type="text/javascript" src="@(Model.SignalRServiceUrl)/signalr/hubs"></script>
}


<div id="maskContainer">
    <div class="datagrid-mask" style="display: block;"></div>
    <div class="datagrid-mask-msg" style="display: block; left: 50%; margin-left: -52.5px; font-size:12px;">
        正在加载...
    </div>
</div>

<div id="home-layout" class="easyui-layout hidden" data-options="fit:true" style="padding: 0px; margin: 0px;">
    <div id="home-north" data-options="region:'north',border:false,collapsed:@(Model.North ? "true" : "false")" style="height: 81px; overflow: hidden;">
        <div id="north-topbar" class="top-bar">
            <div id="topbanner" class="top-bar-left">
                <div id="divLogo" class="logo"></div>
                <span id="sysNameSpan">@Model.SystemName</span>
            </div>
            <div class="top-bar-right">
                <div id="timerSpan">
                    <label id="nowTime"></label>
                </div>
                <div id="themeSpan">
                    <span>更换皮肤风格：</span>
                    <input id="themeSelector" />
                    <a id="btnHideNorth" class="easyui-linkbutton" data-options="plain: true, iconCls: 'layout-button-up'"></a>
                </div>
            </div>
        </div>
        <div id="north-toolbar" class="panel-header panel-header-noborder top-toolbar">
            <div id="userbar">
                <span id="welcomeInfo"></span>
            </div>

            <div id="buttonbar">
                <a id="a3" href="javascript:void(0);" class="easyui-linkbutton easyui-tooltip" data-options="iconCls:'icon-password',plain:true,content:'修改密码'">修改密码</a>
                <a id="a5" href="javascript:void(0);" class="easyui-linkbutton easyui-tooltip" data-options="iconCls:'icon-logout',plain:true,content:'注销登录'">注销登录</a>
                <a id="btnShowNorth" class="easyui-linkbutton" data-options="plain: true, iconCls: 'layout-button-down'" style="display: none;"></a>
            </div>
        </div>
    </div>

    <div id="home-west" data-options="region:'west',title:'菜单导航栏',split:true,iconCls:'icon-standard-map',minWidth:155,maxWidth:240,collapsed:@(Model.West ? "true" : "false")" style="width: 165px; padding: 1px;">
        <div id="navTab" class="easyui-tabs" data-options="fit: true, border: true, tools: [{ id: 'navMenu_refresh', iconCls: 'icon-hamburg-refresh' }]">
            <div data-options="title: '导航菜单', iconCls: 'icon-standard-application-view-tile', refreshable: false, selected: true">
                <div id="westLayout" class="easyui-layout" data-options="fit:true">
                    <div data-options="region: 'center', border: false" style="border-bottom-width: 1px;">
                        <ul id="navMenu_Tree" class="easyui-tree" style="padding-top: 2px; padding-bottom: 2px;"></ul>
                    </div>
                    <div id="westSouthPanel" data-options="region: 'south', border: false, split: true, minHeight: 32, maxHeight: 275" style="height: 275px; border-top-width: 1px;">
                        <ul id="navMenu_list"></ul>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div id="home-center" data-options="region:'center'" style="padding: 1px;">
        <div id="mainTab" class="easyui-tabs" data-options="fit: true, border: true, showOption: true, enableNewTabMenu: true, repeatable: true">

        </div>
    </div>

    <div id="home-south" data-options="region:'south',collapsed: true,title: '关于信息',border:false,iconCls:'icon-about',collapsed:@(Model.South ? "true" : "false")" style="height: 75px; background: #efefef;">
        <div style="color: #4e5766; padding: 8px 0px 0px 0px; margin: 0px auto; text-align: center; font-size: 12px; font-family: 微软雅黑;">
            #2012-2014 Copyright: 落阳&nbsp;&nbsp;|&nbsp;&nbsp;
            <a href="http://www.baidu.com" target="_blank" style="text-decoration: none;">关于</a><br />
            建议使用&nbsp;
            <a href="http://windows.microsoft.com/zh-CN/internet-explorer/products/ie/home" target="_blank"
               style="text-decoration: none;">IE(Version 9/10)</a>/
            <a href="https://www.google.com/intl/zh-CN/chrome/browser/" target="_blank" style="text-decoration: none;">Chrome</a>
            &nbsp;系列浏览器。<br />
        </div>
    </div>
</div>


<script>
    var userName = "@Model.Account"; var connectID;

    $(function () {
        window.startup("@Model.North".toBoolean(), "@Model.DefaultRootMenuID", "@Model.DefaultThemeName");

        var use = "@Model.UserPool".toBoolean();
        if (use) {
            var chat = $.connection["@Model.SignalRHubName"];
            $.connection.hub.url = "@(Model.SignalRServiceUrl)/signalr";


            if (chat != undefined) {
                chat.client.getWelcomeInfo = function (info, conId) {
                    $("#welcomeInfo").html("@Model.RealName" + info);
                }

                //显示公共信息
                chat.client.getPublicInfo = function (sender, info) {
                    //$("#pushInfo").append(info + "<br />");
                };

                //显示推送信息
                chat.client.getPushInfo = function (sender, info) {
                    //$("#welcomeInfo").append(info);
                    $.messager.alert(info);
                };

                chat.client.stopClient = function () {
                    chat.connection.stop();
                }

                $.connection.hub.start().done(function () {
                    connectID = $.connection.hub.id;
                    chat.server.registeUserConnect(userName, "@Model.Token", "@Model.SiteSignalRGroupName");

                    //注销登录按钮方法涉及到注销signalR，因此在这里绑定事件
                    $("a#a5", "#buttonbar").click(function () {
                        window.mainpage.logoutConfirmAndExit(function () {
                            $.easyui.loading({ locale: $("body"), msg: "正在注销，请稍等..." });
                        }, function () {
                            try {
                                chat.server.removeConnectSingleByConnectId(connectID, true);
                            }
                            catch (er) {

                            }
                        });
                    });
                });
            }
            else {
                $("a#a5", "#buttonbar").click(function () {
                    window.mainpage.logoutConfirmAndExit(function () { $.easyui.loading({ locale: $("body"), msg: "正在注销，请稍等..." }); });
                });
            }
        }
        else {
            $("#welcomeInfo").html("@Model.RealName" + "，欢迎您！");

            $("a#a5", "#buttonbar").click(function () {
                window.mainpage.logoutConfirmAndExit(function () { $.easyui.loading({ locale: $("body"), msg: "正在注销，请稍等..." }); });
            });
        }
    });
</script>